<%--
  Created by IntelliJ IDEA.
  User: 陈帅玺
  Date: 2019-02-16
  Time: 16:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>销售机会</title>
</head>
<link rel="stylesheet" href="/assets/css/loader-style.css">
<link rel="stylesheet" href="/assets/css/bootstrap.css">
<link rel="stylesheet" href="/layui/css/layui.css">
<script src="/js/jquery-3.3.1.js"></script>
<script src="/layui/layui.js"></script>
<script src="/js/config.js"></script>
<link rel="shortcut icon" href="/assets/ico/minus.png">
<style>
    #detail,#aa,#xiugai,#plan,#planupdate,#select{
        display: none;
        padding: 30px 50px 0 50px;
    }
</style>
<body>
<%--分配--%>
<div id="aa">
    <form class="layui-form" id="distriForm">
        <%-- 数据编号--%>
        <input type="hidden" name="id" id="sid">
            <%-- 状态--%>
        <input type="hidden" name="stat"  value="20">
            <%--分配人的id--%>
        <input type="hidden" name="assign" id="assign"  value="">
            <%--职位id--%>
        <input type="hidden" name="userid" id="userid"  value="${sessionScope.crmRole.id}">
            <div class="layui-form-item">
                <label class="layui-form-label">分配人角色：</label>
                <div class="layui-inline">
                    <select lay-filter="myselect">
                        <option value="">请选择角色</option>
                        <c:forEach items="${list}" var="ls">
                            <option value="${ls.id}">${ls.rolename}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分配给：</label>
                <div class="layui-inline">
                    <select id="roles" name="assigner" lay-filter="myselect2" >
                        <option value="-1">请选择</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">分配时间：</label>
                <div class="layui-input-inline">
                    <input type="text" name="assignTime" id="distriTime" class="layui-input" readonly>
                </div>
            </div>
    </form>
</div>
<%--增加--%>
<div id="detail">
    <form class="layui-form" id="detailForm" lay-filter="detailForm">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">机会名称：</label>
                <div class="layui-input-inline">
                    <input type="text" name="source" id="a" class="layui-input" >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">机会描述:</label>
                <div class="layui-input-inline">
                    <input type="text" name="outline" id="b" class="layui-input" >
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="linkman" id="c" class="layui-input" >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">机会编号：</label>
                <div class="layui-input-inline">
                    <input type="text" name="chatid" id="e"  class="layui-input" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系电话：</label>
                <div class="layui-input-inline">
                    <input type="text" name="linkphone" id="d"  class="layui-input" >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">创建人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" value="${login_user.username}" readonly >
                </div>
            </div>
            <input type="hidden" value="19" name="Stat">
        </div>
    </form>
</div>
<%--修改--%>
<div id="xiugai">
    <form class="layui-form" id="detailForms" lay-filter="detailForms">
        <input type="hidden" name="id" id="idss" value="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">机会名称：</label>
                <div class="layui-input-inline">
                    <input type="text" name="source" id="jihui" class="layui-input" >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">机会描述:</label>
                <div class="layui-input-inline">
                    <input type="text" name="outline" id="miaoshu" class="layui-input" >
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="linkman" id="lianxiren" class="layui-input" >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">联系电话：</label>
                <div class="layui-input-inline">
                    <input type="text" name="linkphone" id="phone" class="layui-input" >
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">创建人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" value="${login_user.username}" readonly >
                </div>
            </div>
            <input type="hidden" value="19" name="Stat">
        </div>
    </form>
</div>
<%--计划开发--%>
<div id="plan">
    <table class="layui-table" lay-filter="planTable" id="planTable"></table>
    <form class="layui-form" id="planAddForm" style="margin-top: 100px" lay-filter="planAddForm">
        <input type="hidden" name="planid" id="jihuaid">
        <div class="layui-form-item">
            <label class="layui-form-label">日期：</label>
            <div class="layui-input-inline">
                <input type="text" name="timer" class="layui-input" id="planDate" placeholder="yyyy-MM-dd" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">计划内容：</label>
            <div class="layui-input-block">
                <input type="text" name="neirong" id="neirong" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">计划效果：</label>
            <div class="layui-input-block">
                <input type="text" name="xiaoguo" id="xiaoguo" class="layui-input">
            </div>
        </div>
        <%--<button type="button" class="layui-btn" style="margin-bottom: 10px; float: right;" onclick="planAdd()">制定</button>--%>
    </form>
</div>
<%--修改计划--%>
<div id="planupdate">
    <form class="layui-form" id="planAddFormupdate" lay-filter="planAddFormupdate">
        <input type="hidden" name="id" id="planjihuiid">
        <div class="layui-form-item">
            <label class="layui-form-label">日期：</label>
            <div class="layui-input-inline">
                <input type="text" name="timer" class="layui-input" id="planDate1" placeholder="yyyy-MM-dd" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">计划内容：</label>
            <div class="layui-input-block">
                <input type="text" name="neirong" id="neirong1" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">计划效果：</label>
            <div class="layui-input-block">
                <input type="text" name="xiaoguo" id="xiaoguo1" class="layui-input">
            </div>
        </div>
        <%--<button type="button" class="layui-btn" style="margin-bottom: 10px; float: right;" onclick="planAdd()">制定</button>--%>
    </form>
</div>
<%--查看机会--%>
<div id="select">
    <form class="layui-form" id="selectForm" lay-filter="selectForm">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">机会名称：</label>
                <div class="layui-input-inline">
                    <input type="text" name="source" id="jihuimingcheng" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">机会描述:</label>
                <div class="layui-input-inline">
                    <input type="text" name="outline" id="jihuimiaoshu"  class="layui-input" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="linkman" id="lianxirens"  class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">联系电话：</label>
                <div class="layui-input-inline">
                    <input type="text" name="linkphone" id="xldianhua"   class="layui-input" readonly>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">创建人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="chuangjianren"  readonly >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">创建时间：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="chuangjianshijian"  readonly >
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">分配人：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="fenpeiren"  readonly >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">分配时间：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="fenpeishijian"  readonly >
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">状态：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="zhuangtai"  readonly >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">开发时间：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="kafashijian"  readonly >
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">开发内容：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="kafaneirong"  readonly >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">开发效果：</label>
                <div class="layui-input-inline">
                    <input type="text" name="" class="layui-input" id="kaifaxiaoguo" readonly >
                </div>
            </div>
        </div>
    </form>
</div>
<%--创建成功以后加入到客户表--%>
<div id="success">
    <form class="layui-form" id="successForm" lay-filter="successForm">
        <%--登录人的id--%>
        <%--<input type="text" name="userId" id="denglu">--%>
        <%--客户编号--%>
        <input type="hidden" name="custId" id="bianhao">
        <%--客户姓名--%>
        <input type="hidden" name="custName" id="name">
        <%--客户等级--%>
        <input type="hidden" name="level" value="1">
        <%--客户满意度--%>
        <input type="hidden" name="satisfied" value="11">
        <%--客户信用度--%>
        <input type="hidden" name="credit" value="16">
        <%--手机号--%>
        <input type="hidden" name="phone" id="phonesss">
        <%--状态--%>
        <input type="hidden" name="stat" value="23">
            <%--地区--%>
            <input type="hidden" name="region" >
            <%--邮箱--%>
            <input type="hidden" name="email" >
            <%--d地址--%>
            <input type="hidden" name="address" >
            <%--分配状态--%>
            <input type="hidden" name="fenpeistat" >


    </form>
</div>
<h2>销售机会管理</h2>
<hr>
<%--<form class="layui-form" action="">--%>
    <%--<div class="layui-form-item">--%>
        <%--<div class="layui-inline">--%>
            <%--<label class="layui-form-label">客户名:</label>--%>
            <%--<div class="layui-input-inline" style="width: 200px">--%>
                <%--<input id="username" type="text" autocomplete="off" class="layui-input">--%>
            <%--</div>--%>
            <%--<label class="layui-form-label">状态:</label>--%>
            <%--<div class="layui-input-inline" style="width: 300px">--%>
                <%--<select id="statsasasas" class="layui-input">--%>
                    <%--<option value="-1">请选择</option>--%>
                    <%--&lt;%&ndash;<c:forEach items="${crmDictionaries}" var="a">&ndash;%&gt;--%>
                        <%--&lt;%&ndash;<option value="${a.id}">${a.name}</option>&ndash;%&gt;--%>
                    <%--&lt;%&ndash;</c:forEach>&ndash;%&gt;--%>
                <%--</select>--%>
            <%--</div>--%>
            <%--<div class="layui-input-inline" style="width: 200px">--%>
                <%--<button type="button" class="layui-btn" onclick="SearchData();"><i class="layui-icon layui-icon-search"></i>查询</button>--%>
            <%--</div>--%>
        <%--</div>--%>
    <%--</div>--%>
<%--</form>--%>
<table class="layui-table" lay-data="{url:'/xiaoshou/neirong',page:true, id:'userTable',toolbar:'#toolbarDemo',defaultToolbar: ['filter', 'print', 'exports'],even: true}" lay-filter="userTable">
    <thead>
    <tr>
        <th lay-data="{type:'checkbox'}"></th>
        <th lay-data="{field:'chatid', width:100}">机会编号</th>
        <th lay-data="{field:'source', width:180}">机会名称</th>
        <th lay-data="{field:'outline', width:200}">机会描述</th>
        <th lay-data="{field:'linkman', width:110}">联系人</th>
        <th lay-data="{field:'linkphone', width:120}">联系人电话</th>
        <th lay-data="{field:'creatorTime', width:110}">创建时间</th>
        <th lay-data="{templet:'#stat', width:120}">状态</th>
        <th lay-data="{toolbar:'#barDemo'}">操作</th>
    </tr>
    </thead>
</table>
<script>
    <%--分配人员--%>
    <%--$.get("${path}/Service/search",function (data) {--%>
        <%--$.each(data,function () {--%>
            <%--var opt = $("<option></option>").appendTo("#roles");--%>
            <%--opt.text(this.username).val(this.id);--%>
        <%--});--%>
    <%--})--%>
    <%--$.get("${path}/loss/search",function (data) {--%>
        <%--$.each(data,function () {--%>
            <%--var opt = $("<option></option>").appendTo("#statsasasas");--%>
            <%--opt.text(this.name).val(this.id);--%>
        <%--})--%>
    <%--})--%>
    layui.use(["layer","table","form"],function () {
        layui.form.render();
        table = layui.table;

        var layer = layui.layer
            ,form = layui.form;
        form.on('select(myselect)', function(data){
            $("#roles").empty();
            // $("#matter").empty();
            form.render('select');
            // $("#price").empty();
            //查询单元
            $.post("${path}/xiaoshou/roleidddd",{'id':data.value},function (str) {
                $.each(str.data, function(idx,obj) {
                    var option1 = $("<option>").val(obj.id).text(obj.username);
                    $("#roles").append(option1);
                    form.render('select');
                });
                $("#roles").get(0).selectedIndex=0;
            })
        })


            table.on("toolbar(userTable)",function (obj) {
            var data=obj.data;
            switch (obj.event) {
                //增加人员
                case "add":
                    var s="0123456789";
                    var a=6;
                    var d="ABCDEFGHIJKLMNOPQRSTUVMXYZ";
                    var e=2;
                    var z="";
                    var y="";
                    for (var j=0;j<e;j++){
                        var aa=Math.random()*10;
                        var aaa=Math.floor(aa);
                        z=z+d[aaa];
                    }
                    for (var i=0;i<a;i++){
                        var b=Math.random()*10;
                        var c=Math.floor(b);
                        y=y+s[c];
                    }
                    var zuhe=z+y;
                    $("#e").val(zuhe);
                    layer.open({
                        type: 1,
                        title: "增加机会",
                        skin: "layui-layer-molv",
                        anim: 0,
                        offset:'240px',
                        area: "900px",
                        content: $("#detail"),
                        btn: ['确定','取消'],
                        yes : function (index) {
                            var str = $("#detailForm").serialize();
                            console.log(str);
                            $.post("${path}/xiaoshou/add",str,function (){
                                layer.msg("提交成功...",{time:1200})
                                layer.close(index);
                                table.reload('userTable');
                                $("#a").val('');
                                $("#b").val('');
                                $("#c").val('');
                                $("#d").val('');
                            });
                        }
                    })
                    break;
                //    删除人员
                case "batchDelete":
                    var rows = table.checkStatus('userTable');
                    var data = rows.data;
                    if(data.length == 0){
                        layer.msg("请选择要删除的数据",function(){});
                        return;
                    }
                    layer.confirm('确定要删除这么多数据吗？',{icon:5,title:'友情提示'},function (index) {
                        var params = "";
                        for(let userTable of data){
                            params += "ids="+userTable.id+"&";
                        }
                        $.post('${path}/xiaoshou/batchDelete',params,function () {
                            layer.close(index);
                            table.reload('userTable');
                        });
                    });
                    break;
            }
        })
        //分配人员
        table.on('tool(userTable)',function (obj) {
            var e = obj.event;
            var data=obj.data;
            console.log(data);
            $("#sid").val(data.id)
            switch (e){
                case "selectplan":
                    layer.open({
                        type: 1,
                        title: "查看计划",
                        skin: "layui-layer-molv",
                        anim: 0,
                        offset:'240px',
                        area: "900px",
                        content: $("#select"),
                        btn: ['返回'],
                        success:function () {
                            console.log(data)
                            $("#jihuimingcheng").val(data.source);
                            $("#jihuimiaoshu").val(data.outline);
                            $("#lianxirens").val(data.linkman);
                            $("#xldianhua").val(data.linkphone);
                            $("#chuangjianren").val(data.changjianpeople.username);
                            $("#chuangjianshijian").val(data.creatorTime);
                            $("#fenpeiren").val(data.fenpeiren.username);
                            $("#fenpeishijian").val(data.assignTime);
                            $("#zhuangtai").val(data.zhuangtai.name);
                            $("#kafashijian").val(data.timer);
                            $("#kafaneirong").val(data.neirong);
                            $("#kaifaxiaoguo").val(data.xiaoguo);
                        }

                    })
                    break;
                case "distri":
                    if (data.zhuangtai.id== 20) {
                        layer.msg('请选择未分配的数据行...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 21) {
                        layer.msg('该机会已开发成功...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 22) {
                        layer.msg('抱歉,该机会已开发失败...',{offset:'260px'});
                        return;
                    }
                    layer.open({
                        type: 1,
                        title: "分配人员",
                        skin: "layui-layer-molv",
                        anim: 0,
                        offset:"260px;",
                        area: "550px",
                        content: $("#aa"),
                        btn: ['确定','取消'],
                        yes : function (index) {
                            var role=$("#roles").val();  //判断是否为空
                            if(role==-1){
                                layer.msg("仔细填写...",{icon:5,time:1200,anim:6},function () {});
                                return false;
                            }
                            var aaa=($("#roles").val());  //分配人的id
                            $("#assign").val(aaa);
                            var str = $("#distriForm").serialize();
                            console.log(str);
                            $.post("${path}/xiaoshou/updatefenpei",str,function (){
                                layer.close(index);
                                table.reload('userTable');
                            });

                        }
                    })
                    break;
                //    修改信息
                case "edit":
                    if (data.zhuangtai.id== 20) {
                        layer.msg('抱歉，该机会已指派无法修改...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 21) {
                        layer.msg('该机会已开发成功...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 22) {
                        layer.msg('抱歉,该机会已开发失败...',{offset:'260px'});
                        return;
                    }
                    layer.open({
                        type: 1,
                        title: "修改",
                        skin: "layui-layer-molv",
                        anim: 0,
                        offset:"260px;",
                        area: "550px",
                        content: $("#xiugai"),
                        btn: ['确定','取消'],
                        success:function(){
                            $("#jihui").val(data.source);
                            $("#miaoshu").val(data.outline);
                            $("#lianxiren").val(data.linkman);
                            $("#phone").val(data.linkphone);
                            $("#idss").val(data.id);
                        },
                        yes : function (index) {
                            var a=$("#jihui").val();
                            var b=$("#miaoshu").val();
                            var c=$("#lianxiren").val();
                            var d=$("#phone").val();
                            if(a=="" || b=="" || c=="" || d==""){
                                layer.msg("仔细填写...",{icon:5,time:1200,anim:6},function () {});
                                return false;
                            }
                            var str = $("#detailForms").serialize();
                            console.log(str);
                            $.post("${path}/xiaoshou/update",str,function (){
                                layer.close(index);
                                table.reload('userTable');
                            });

                        }
                    })
                    break;
                case "queren":
                    if (data.zhuangtai.id== 19) {
                        layer.msg('抱歉,该机会未分配...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 21) {
                        layer.msg('该机会已开发成功...',{offset:'260px'});
                        return;
                    }
                    $("#denglu").val(data.changjianpeople.id);
                    $("#bianhao").val(data.chatid);
                    $("#name").val(data.linkman);
                    $("#phonesss").val(data.linkphone);
                    var successForms=$("#successForm").serialize();
                    console.log(successForms);
                    $.post  ("${pageContext.request.contextPath}/customers/add",successForms,function () {
                        layer.confirm('确定要开发吗？', function (index) {
                            $.post("${pageContext.request.contextPath}/xiaoshou/updatezhuangtai",{"id":data.id},function () {
                                layer.msg("增加成功...",{"time":1000},function () {
                                    layer.closeAll();
                                    table.reload('userTable');
                                })

                            })

                        })
                    })
                    break;
                case "plan":
                    if (data.zhuangtai.id== 19) {
                        layer.msg('抱歉,该机会未分配...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 21) {
                        layer.msg('该机会已开发成功...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 22) {
                        layer.msg('抱歉,该机会已开发失败...',{offset:'260px'});
                        return;
                    }
                    if (data.zhuangtai.id== 35) {
                        layer.msg('抱歉,该机会已处于待审核状态...',{offset:'260px'});
                        return;
                    }
                    $("#jihuaid").val(data.id)
                    console.log(data);
                    layer.open({
                        type: 1,
                        title: "客户开发计划管理",
                        skin: "layui-layer-molv",
                        anim: 0,
                        offset:"260px",
                        area: "800px",
                        content: $("#plan"),
                        btn: ['制定','返回'],
                        success: function () {
                            //  添加计划表格
                            table.render({
                                elem: '#planTable'
                                ,url:'${path}/plan/select?planid=' + data.id
                                ,text: {none: '没有查到相关数据'}
                                ,even: true
                                ,page : true
                                ,limit : 10
                                ,toolbar: "#planTopDemo"
                                ,cols: [[
                                    {type: 'radio'},
                                    {field:'timer', width:105, title: '日期'}
                                    ,{field:'neirong', title: '计划内容'}
                                    ,{field:'xiaoguo', title: '计划效果'}
                                    ,{toolbar:'#planDemo', width:120, title: '操作'}
                                ]]
                            });
                        },
                        yes:function (index) {

                            var str=$("#planAddForm").serialize();
                            console.log(str);
                            $.post("${pageContext.request.contextPath}/plan/add",str,function (data) {
                                if(data.code==0){
                                    layer.msg(data.msg,{icon:5});
                                }
                                table.reload('planTable');
                                $("#neirong").val('');
                                $("#xiaoguo").val('');
                            })

                        }
                    });
                    break;
            }
        })
    //    修改和删除开发计划
        table.on('tool(planTable)',function (obj) {
            var data=obj.data;
            switch (obj.event) {
                case "editjiahu":
                    console.log(data)
                    layer.open({
                        type: 1,
                        title: "修改",
                        skin: "layui-layer-molv",
                        anim: 0,
                        offset:"300px;",
                        area: "550px",
                        content: $("#planupdate"),
                        btn: ['确定','取消'],
                        success:function(){
                            $("#planDate1").val(data.timer);
                            $("#neirong1").val(data.neirong);
                            $("#xiaoguo1").val(data.xiaoguo);
                            $("#planjihuiid").val(data.id);
                        },
                        yes : function (index) {
                            var str=$("#planAddFormupdate").serialize();
                            $.post("${pageContext.request.contextPath}/plan/update",str,function () {
                                layer.close(index);
                                table.reload('planTable');

                            })
                            $("#shijian").val(data.timer)
                            console.log(data)

                        }
                    })
                    break;
                case "deljihua":
                    layer.confirm('确定要删除吗？',{icon:5,title:'友情提示'},function (index) {
                        $.post('${path}/plan/del',{"id":data.id},function () {
                            layer.close(index);
                            table.reload('planTable');
                        });
                    });
                    break;
            }
        })
        //监听单选框事件
        table.on("radio(planTable)",function (obj) {
            var data=obj.data;
            //开发计划的按钮
            table.on('toolbar(planTable)',function (obj) {
                switch (obj.event) {
                    case "success":
                        // var successForms=$("#successForm").serialize();
                        // console.log(successForms);
                        <%--$.post  ("${pageContext.request.contextPath}/customers/add",successForms,function () {--%>
                            layer.confirm('真的要开发成功吗？', function (index) {
                                $.post("${pageContext.request.contextPath}/plan/updatajihua",{
                                    "timer":data.timer
                                    ,"neirong":data.neirong
                                    ,"xiaoguo":data.xiaoguo
                                    ,"id":data.planid
                                    ,"stat":35
                                },function () {
                                    layer.msg("增加成功...",{"time":1000},function () {
                                        layer.closeAll();
                                        table.reload('userTable');
                                    })

                                })

                            })
                        // })
                        break;
                    case "failure":
                        $.post("${pageContext.request.contextPath}/plan/updatajihua",{"timer":data.timer,"neirong":data.neirong,"xiaoguo":data.xiaoguo,"id":data.planid,"stat":22},function () {
                            layer.confirm('确定开发失败吗？', function (index) {
                                layer.closeAll();
                                table.reload('userTable');
                            })
                        })
                        break;
                }
            })
        })

    })

    // function SearchData() {
    //     alert($("#stats").val())
    //     layui.table.reload("userTable",{
    //         page:{
    //             curr:1
    //         },
    //         where:{
    //             "source":$("#username").val(),
    //             "stat":$("#statsasasas").val()
    //         }
    //     })
    // }
    //  获取时间
    function getNow(s) {
        return s < 10 ? '0' + s : s;
    }

    function dates() {
        var now = new Date();
        //格式化日，如果小于9，前面补0
        var day = ("0" + now.getDate()).slice(-2);
        //格式化月，如果小于9，前面补0
        var month = ("0" + (now.getMonth() + 1)).slice(-2);
        // var h = now.getHours();
        // var minute = now.getMinutes();
        // var s = now.getSeconds();
        //拼装完整日期格式
        var today = now.getFullYear() + "-" + (month) + "-" + (day);
        return today;
    }
    $("#distriTime").val(dates());
    $("#planDate").val(dates());
    $("#planDate1").val(dates())
</script>
<script id="stat" type="text/html">
    {{d.zhuangtai.name}}
</script>
<%--增加、批量管理--%>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <shiro:hasPermission name="xiaoshou:add">
            <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-circle"></i>添加</button>
        </shiro:hasPermission>
        <shiro:hasPermission name="xiaoshou:batchDelete">
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batchDelete"><i class="layui-icon layui-icon-delete"></i>批量删除</button>
        </shiro:hasPermission>
    </div>
</script>
<%--显示修改、分配、计划分配--%>
<script type="text/html" id="barDemo">
    {{#  if(d.zhuangtai.id==21){ }}
    <a class="layui-btn layui-btn-xs " lay-event="selectplan" title="查看"><span class="layui-icon layui-icon-list"></span></a>
    {{#  } }}
    {{#  if(d.zhuangtai.id==22){ }}
    <a class="layui-btn layui-btn-xs " lay-event="selectplan" title="查看"><span class="layui-icon layui-icon-list"></span></a>
    {{#  } }}
    <shiro:hasPermission name="xiaoshou:update">
        <a class="layui-btn layui-btn-xs " lay-event="edit" title="修改"><span class="layui-icon layui-icon-edit"></span></a>
    </shiro:hasPermission>
    <shiro:hasPermission name="xiaoshou:updatefenpei">
        <a class="layui-btn layui-btn-xs " lay-event="distri" title="分配"><span class="layui-icon layui-icon-release"></span></a>
    </shiro:hasPermission>
    {{#  if(d.zhuangtai.id==35){ }}
    <a class="layui-btn layui-btn-xs" lay-event="queren" title="确认"><span class="layui-icon layui-icon-ok-circle"></span></a>
    {{#  } }}
    <shiro:hasPermission name="plan:select">
        <a class="layui-btn layui-btn-xs" lay-event="plan" title="计划管理"><span class="layui-icon layui-icon-tabs"></span></a>
    </shiro:hasPermission>

</script>
<%--分配计划的按钮--%>
<script type="text/html" id="planTopDemo">
    <div class="layui-btn-container">
        <a class="layui-btn layui-btn-xs " lay-event="success" title="开发成功"><span class="layui-icon layui-icon-ok"></span></a>
        <a class="layui-btn layui-btn-xs " lay-event="failure" title="开发失败"><span class="layui-icon layui-icon-close"></span></a>
    </div>
</script>
<%--修改删除开发计划--%>
<script id="planDemo" type="text/html">
    <a class="layui-btn layui-btn-xs " lay-event="editjiahu" title="修改"><span class="layui-icon layui-icon-edit"></span></a>
    <a class="layui-btn layui-btn-xs " lay-event="deljihua" title="修改"><span class="layui-icon layui-icon-delete"></span></a>
</script>
<script type="text/html" id="keTem">
    <a href="javascript:void(0)" onclick="AAA()" class="layui-table-link">{{d.kename}}</a>
</script>
<script>
    function AAA() {
        alert("123123")
    }
</script>
</body>
</html>
